/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * Nihongo
 * Copyright (C) Massimiliano Maniscalco 2011, 2012 <massi.neptune@yahoo.com>
 * 
Nihongo is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Nihongo is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _TESTSCELTAMULTPAROLE_H_
#define _TESTSCELTAMULTPAROLE_H_

#include "test_scelta_mult.h"
#include "parola.h"
#include "result_test_parole.h"

#define MOD_PAROLE_MEMORY			0
#define MOD_PAROLE_READING			2
#define JAP_ITA						false


class TestSceltaMultParole: public TestSceltaMult 
{
public:
	inline TestSceltaMultParole ( Glib::RefPtr<Gtk::Builder> _bldr, list<Parola> *sel, list<Parola> *all );
	inline ~TestSceltaMultParole ();
	void run_test ( char *options );

protected:
	// grammatica
	bool _isGrammatica;
	char _isCortese;
	char _isAffermativa;
	char _formaScelta;
	bool _cortScelta;
	bool _affScelta;
	
	void update_window ( void );
	void possibili_risposte ( Glib::ustring &risp1, Glib::ustring &risp2, Glib::ustring &risp3, Glib::ustring &risp4 );
	void possibili_risposte_grammatica ( Glib::ustring *_rispArray, char _rispostaBuona );
	const Parola* prendi_parola_casuale ( void );
	Glib::ustring crea_etichetta ( const Parola &par );
	void on_risposta ( char tasto = -1 );
	void nome_coniugazione ( Glib::ustring &str, char _index = 0 );
	void forma_coniugata ( Glib::ustring &str, char _index = 0, bool _cortesia = true, bool _affermativa = true );
	void next_question ( void );
	bool show_result ( void );

private:
	list<Parola> *_contenuto;
	list<Parola> *_tutte;
	list<Parola>::iterator _parolaCorrente;
	ResultTestParole *_resultCtrl;
	
};

inline TestSceltaMultParole::
TestSceltaMultParole ( Glib::RefPtr<Gtk::Builder> _bldr, list<Parola> *sel, list<Parola> *all )
: _contenuto ( sel ), _tutte ( all ), _parolaCorrente ( sel->begin() ), _resultCtrl ( new ResultTestParole ( _bldr, sel ) )
{
	init_test_scelta_mult ( _bldr );
	connect_signals ();
	_resultCtrlConnection = _resultCtrl->signal_window_closed ().connect (sigc::mem_fun (this, &TestSceltaMultParole::on_result_window_closed) );
}

inline TestSceltaMultParole::
~TestSceltaMultParole ()
{
	delete _resultCtrl;
	delete _contenuto;
}

#endif // _TESTSCELTAMULTPAROLE_H_
